/*  

Cafechess Library: Cover basic chess programming needs, like GUI, Engine integration, 
FEN and PGN parsing.

                 \\|//
                 (o o)
--------------ooO-(_)-Ooo----------------------------------
Copyright (C) 2009  By Gregory A. Prentice Snoqualmie, WA
                    www.cafechess.org
                    cafechess@comcast.net
                      Oooo
--------------oooO----(  )---------------------------------
              (  )    (_/
               \_)

Microsoft Public License (Ms-PL)
               
Revisions:

Author        Date    Description:

*/

using System;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;

using Cafechess.Imaging;
using Cafechess.Imaging.Draw;
using Cafechess.Chess.General;
using Cafechess.Chess.Validation;
using Cafechess.Chess.Parsers;

namespace Cafechess.Chess.Controls
{
  /// <summary>
  /// This is the main interface point to the chess control by third party
  /// users of the control it self.
  /// </summary>
  public interface IChessboardGui
  {
    /// <summary>
    /// The width of the board in pixels.  A value of zero will turn off
    /// the border.
    /// </summary>
    int BoarderWidth{ get; set; }
    /// <summary>
    /// Default color used to perform keyboard drawing.
    /// </summary>
    Color DefaultDrawingColor{get;set;}
    /// <summary>
    /// Color for drawing attacked squares.
    /// </summary>
    Color AttacksColor{get;set;}
    /// <summary>
    /// Color of white board square.
    /// </summary>
    Color WhiteColor{get;}
    /// <summary>
    /// Color of black board square.
    /// </summary>
    Color BlackColor{get;}
    /// <summary>
    /// Color of the boarder.
    /// </summary>
    Color BoarderColor{get;}
    /// <summary>
    /// Default penwidth to perform keyboard drawing.
    /// </summary>
    int DefaultPenWidth{get;set;}
    /// <summary>
    /// Disallows a particular side from moving
    /// GUI pieces around with a mouse.  Moves should be
    /// passed to the IValidation.Move method for non gui
    /// interactions.  Used to interface with an engine
    /// or internet opponent.
    /// </summary>
    MoveGeneration MoveInput{get;set;}    
    /// <summary>
    /// Allows you to determine which side to display on the bottom.  A
    /// value of false will show starndard from whites perspective while
    /// true will display black on the bottom.
    /// </summary>
    bool IsFlipped{ get; set; }
    /// <summary>
    /// Used to signal if we want to redraw the control.
    /// </summary>
    bool IsRedraw{ get; set; }
    /// <summary>
    /// When set to true the validation is disabled and you can freely move the pieces.
    /// May add the ability to turn on drawing features like arrows and cirlces.
    /// </summary>
    bool IsEditting{ get; set; }
    /// <summary>
    /// Use to signal that we want to start using mouse/keyboard commands to begin drawing.
    /// </summary>
    bool IsDrawing{get;set;}
    /// <summary>
    /// When set to false then when you move a piece it is not displayed while dragging.
    /// </summary>
    bool IsShowPieceDragging{get;set;}

    /// <summary>
    /// Sets or gets the current chess position using standard FEN notation.
    /// </summary>
    string FenNotation{ get; set; }
    /// <summary>
    /// Used to determine the formatting string for the getter for the FenNotation property.
    /// The standard format is: "{0} {1} {2} {3} {4} {5}" where each represents:
    ///   {0} the board / piece layout.
    ///   {1} color to move
    ///   {2} castling
    ///   {3} enpasant
    ///   {4} half move
    ///   {5} full move
    /// </summary>
    string FenFormat{get; set; }
    /// <summary>
    /// The fen notation for the graphical Piece display only, used
    /// in the setup of a board when you wish to retreive the FEN
    /// notation for the graphics board and NOT the validator.
    /// </summary>
    string ImageFenNotation{get;}
    /// <summary>
    /// Sets the chess images to use with the current board.
    /// </summary>
    ImageList ChessImages{ set;}
    /// <summary>
    /// Sets up our standard starting position
    /// </summary>
    void NewPosition();
    /// <summary>
    /// Removes all pieces from the board.
    /// </summary>
    void ClearPosition();
    /// <summary>
    /// Gets or sets the interface to our chess validation routines.
    /// </summary>
    IValidation Validation{ get; set; }
    /// <summary>
    /// Allows you to select which layer the associated routines will
    /// </summary>
    Layers ActiveLayer{ get; set; }
    /// <summary>
    /// Gets / Sets the ActiveLayer IsEnabled Flag.
    /// </summary>
    bool IsLayerEnabled{ get; set; }    
    /// <summary>
    /// Gets the ActiveLayer IsDragging Flag, needed to ensure
    /// we aren't interrupting our control in the middle of
    /// a drag and drop opperation.
    /// </summary>
    bool IsLayerDragging{get;}
    /// <summary>
    /// Gets or Sets the format string for the specified layer.
    /// </summary>
    string LayerNotation{get;set;}
    /// <summary>
    /// Removes all IDrawable objects from the specified layer.
    /// </summary>
    void ClearLayer();
    /// <summary>
    /// Put a highlight on the layer that was selected with ActiveLayer.
    /// Note this will only work if the layer is a valid drawing layer.
    /// </summary>
    /// <param name="color">Color to paint highlight, if Color.Transparent then remove the highlight</param>
    /// <param name="width">width of the line</param>
    /// <param name="notation">square to highlight</param>
    void Highlight(Color color, int width, string notation);
    /// <summary>
    /// Draws an arrow from one square to another.
    /// </summary>
    /// <param name="color">Color to paint arrow, if Color.Transparent then remove the highlight</param>
    /// <param name="width">width of line</param>
    /// <param name="from">Algebraic starting sqaure</param>
    /// <param name="to">Algebraic ending square</param>
    void Arrow(Color color, int width, string from, string to);
    /// <summary>
    /// Draws a circle in the square
    /// </summary>
    /// <param name="color">Color to paint Circle, if Color.Transparent then remove the highlight</param>
    /// <param name="width">width of line</param>
    /// <param name="notation">Algebraic starting sqaure</param>
    void Circle(Color color, int width, string notation);
    /// <summary>
    /// Paints an X on a square.
    /// </summary>
    /// <param name="color">Color to paint X, if Color.Transparent then remove the highlight</param>
    /// <param name="width">width of line</param>
    /// <param name="notation">Algebraic starting sqaure</param>
    void Xmarks(Color color, int width, string notation);
    /// <summary>
    /// Used to display a text filled balloon for notation.
    /// </summary>
    /// <param name="text"></param>
    /// <param name="rect"></param>
    void Balloon(string text, int orientation, Rectangle rect);

    /// <summary>
    /// Color to set our outside boarder of the board.
    /// </summary>
    /// <param name="color"></param>
    void ColorBoarder(System.Drawing.Color color);
    /// <summary>
    /// Color to set the chess board squares.
    /// </summary>
    /// <param name="white"></param>
    /// <param name="black"></param>
    void ColorSquares(System.Drawing.Color white, System.Drawing.Color black);   
    /// <summary>
    /// Bitmaps to use to set the chess board squares.
    /// </summary>
    /// <param name="colorWhite"></param>
    /// <param name="colorBlack"></param>
    void ColorSquares(Bitmap colorWhite, Bitmap colorBlack);
    /// <summary>
    /// Allows you to set an alternate square color for the chess board.  Will
    /// create a hatch pattern for the black squares based on the color passed
    /// in.  Should automatically remove any previous highlights that may have been
    /// turned on with a previous call.
    /// </summary>
    /// <param name="squareArray"></param>
    /// <param name="color"></param>
    void AlternateColorSquares(BitArray squareArray, System.Drawing.Color color);
    /// <summary>
    /// Allows you to set an alternate square color for the chess board.  Will
    /// create a hatch pattern for the black squares based on the color passed
    /// in.  Should automatically remove any previous highlights that may have been
    /// turned on with a previous call.  Allows the intensity of the squares to be
    /// varialbe.
    /// </summary>
    /// <param name="squareArray"></param>
    /// <param name="intensity"></param>
    /// <param name="color"></param>
    void AlternateColorSquares(BitArray squareArray, int[] intensity, System.Drawing.Color color);
    /// <summary>
    /// Used to retrieve the Alternating color squares that was last used.
    /// </summary>
    BitArray LastHighlights{get; }
    /// <summary>
    /// Used to retrieve a copy of the current chess image.  User is responsible
    /// for disposing this bitmap.
    /// </summary>
    /// <returns></returns>
    Bitmap ChessImage();
    /// <summary>
    /// Retrieves the rectangle of the requested square.
    /// </summary>
    /// <param name="notation"></param>
    /// <returns></returns>
    Rectangle NotationSquare(string notation);
    /// <summary>
    /// This function will set the requested pieces to hidden so that they will not be displayed.
    /// Used for variants of blindfold chess or simply to hide pieces for board evaluation.
    /// </summary>
    /// <param name="pieces"></param>
    /// <param name="heading"></param>
    void Hide(Pieces pieces, CompassHeading heading);
  }
}
